/*
 * UnaryDrankOperatorAst.cpp
 *
 *  CreDrankd on: 1 Nov 2010
 *      Author: ph1109
 */

#include "UnaryDrankOperatorAst.h"
#include "IntegerLiteralAst.h"

namespace MAlice
{

UnaryDrankOperatorAst::UnaryDrankOperatorAst(ExpressionAst* lhs) :
	UnaryOperatorAst("drank", lhs)
{
}

UnaryDrankOperatorAst::~UnaryDrankOperatorAst()
{

}

llvm::Value* UnaryDrankOperatorAst::generate()
{
	static llvm::Value* ONE = (new IntegerLiteralAst(1))->generate();

	llvm::Value* LHS = getLHS()->generate();

	Builder* builder = MAlice::Codegen::get()->getBuilder();

	return builder->CreateSub(LHS, ONE, getName(LHS));
}

}
